package research.ui.editors.input;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPersistableElement;

import research.entity.Entity;

public class EntityEditorInput implements IEditorInput {
	
	private final Entity entity;
	
	public Entity getEntity() {
		return entity;
	}

	public EntityEditorInput(Entity entity) {
		super();
		this.entity = entity;
	}

	@Override
	public boolean exists() {
		return false;
	}

	@Override
	public ImageDescriptor getImageDescriptor() {
		return ImageDescriptor.getMissingImageDescriptor();
	}

	@Override
	public String getName() {
		return entity.toString();
	}

	@Override
	public IPersistableElement getPersistable() {
		return null;
	}

	@Override
	public String getToolTipText() {
		return entity.toString();
	}

	@Override
	@SuppressWarnings("unchecked")
	public Object getAdapter(Class adapter) {
		return null;
	}

	@Override
	@SuppressWarnings("unchecked")
	public boolean equals(Object obj) {
		if (super.equals(obj))
			return true;
		if (obj instanceof EntityEditorInput) {
			return entity.equals(((EntityEditorInput) obj).getEntity());
		}

		return false;
	}
	
	

}
